﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Vehicle.Web.Pages.Task
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Task_View.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-09-02   Created by 杨光远 V1.00.0000
    /// 功能说明：查看任务单页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Task_View : Component.PageBase
    {
        #region ---基本变量实例化---
        Vehicle.BLL.Task b_Task = new Vehicle.BLL.Task();//定义逻辑层变量
        BLL.Log b_Log = new Vehicle.BLL.Log();
        Vehicle.Model.TaskInfo m_TaskInfo = new Vehicle.Model.TaskInfo();//定义实体层
        Vehicle.BLL.Vehicles b_Vehicles = new Vehicle.BLL.Vehicles();//定义逻辑层变量
        Vehicle.BLL.Motorcade b_Motorcade = new Vehicle.BLL.Motorcade();//定义逻辑层变量
        public string url;
        #endregion

        #region---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {

                TaskDataBind();

            }
        }
    
        /// <summary>
        /// 绑定任务方法
        /// </summary>
        public void TaskDataBind()
        {
            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {

                DataTable dt = b_Task.GetModel(new Vehicle.Model.ComponentsInfo("Task", "T_ID", Request.QueryString["id"].ToString(), "T_ID"));
                if (dt.Rows.Count > 0)
                {
                    try
                    {
                        lab_M_ID.Text = b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo("Motorcade", "M_ID", dt.Rows[0]["M_ID"].ToString(), "M_ID")).Rows[0]["M_Name"].ToString();//绑定车队
                    }
                    catch
                    {
                        lab_M_ID.Text = "无";
                    }
                    try
                    {
                        lab_V_ID.Text = b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo("Vehicles", "V_ID", dt.Rows[0]["V_ID"].ToString(), "V_ID")).Rows[0]["V_LicenseNum"].ToString(); //绑定车辆
                    }
                    catch
                    {
                        lab_V_ID.Text = "无";
                    }
                    try
                    {
                        lab_P_ID.Text = b_Motorcade.GetModel(new Vehicle.Model.ComponentsInfo("Pilot", "P_ID", dt.Rows[0]["P_ID"].ToString(), "P_ID")).Rows[0]["P_Name"].ToString(); //绑定驾驶员
                    }
                    catch
                    {
                        lab_P_ID.Text = "无";
                    }
                    lab_C_Card.Text = dt.Rows[0]["C_Card"].ToString();//绑定任务编号
                    lab_T_Time.Text = dt.Rows[0]["T_Time"].ToString();//绑定任务的时间
                    lab_V_Note.Text = dt.Rows[0]["T_Note"].ToString();//绑定备注
                    lab_T_StarTime.Text =dt.Rows[0]["T_StarTime"].ToString();//具体发车时间
                    lab_T_EndTime.Text =dt.Rows[0]["T_EndTime"].ToString();//具体到达时间
                    lab_T_Type.Text = dt.Rows[0]["T_Type"].ToString();//状态 1执行中 2已完成 	0已取消  
                    switch (lab_T_Type.Text)
                    {
                        case "0": lab_T_Type.Text = "已取消"; break;
                        case "1": lab_T_Type.Text = "执行中"; break;
                        case "2": lab_T_Type.Text = "已完成"; break;
                    }
                    lab_C_Num.Text = dt.Rows[0]["T_Num"].ToString();//任务单编号
                   
                }
                else
                {
                    Common.MessageHelper.AlertBack("该记录已删除!");
                }
            }
            else
            {
                Common.MessageHelper.AlertBack("您的操作有误,请重新尝试!");
            }
        }


        #endregion
    }
}
